package com.bdqn.gulimall.member.web;

import com.alibaba.fastjson.JSON;
import com.bdqn.common.utils.R;
import com.bdqn.gulimall.member.feign.OrderFeignService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * MemberWebController
 *
 * @author f
 * @since 2022/3/9
 */
@Controller
public class MemberWebController {

    @Resource
    OrderFeignService orderFeignService;



    /**
     * 订单分页查询
     * @param pageNum
     * @param model
     * @return
     */
    @GetMapping("memberOrder.html")
    public String memberOrderPage(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                  Model model , HttpServletRequest request){
        //获取支付宝传来的所有请求数据
        // request 验证签名，如果正确可以去修改

        //查出当前登录用户的所有订单列表数据
        Map<String ,Object> page = new HashMap<>();
        page.put("page",pageNum.toString());
        R r = orderFeignService.ListWithItem(page);
        System.out.println(JSON.toJSONString(r));
        model.addAttribute("orders",r);
        return "orderList";
    }
}
